import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/controller/books.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/charts/levelProgressBar.dart';
import 'package:ichinesereader/widgets/grids/bookGridSimplified.dart';

class SimplifiedReadingBody extends StatefulWidget {
  SimplifiedReadingBody({
    Key? key,
  }) : super(key: key);
  _SimplifiedReadingBody createState() => new _SimplifiedReadingBody();
}

class _SimplifiedReadingBody extends State<SimplifiedReadingBody> {
  final BooksController _booksController = Get.find();
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    Log.debug('build simplified ReadingBody');

    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
        Container(
            //margin: EdgeInsets.only(bottom: 9.0),
            width: Get.width - 60,
            height: 26,
            child: LevelProgressIndicatorWidget()),
        const SizedBox(height: 8),
        Flexible(
          child: Center(
            child: _booksController.obx(
              (data) => BookGridSimplified(
                books: _booksController.searchedBookItems
              ),
              onEmpty: Center(child: Text('Books not available'.tr)),
              onLoading: Container(),
            ),
          ),
        ),
      ],
    );
  }
}
